﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Linq.Mapping;
using ECI.Entities;
using ECI.Entities.Builder;

namespace ECI.LIP.Entities
{
    ///<summary>
    ///[SYS_STEP_CONFIG]
    ///</summary>
    [Serializable]
    [Table(Name = "SYS_STEP_CONFIG")]
    public partial class SysStepConfig
    {
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "AUTO_ID")]
        public string AutoId { get { return this._AutoId; } set { this._AutoId = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.AutoId); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "WORKFLOW_TYPE")]
        public string WorkflowType { get { return this._WorkflowType; } set { this._WorkflowType = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.WorkflowType); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "CRNT_STEP_ID")]
        public string CrntStepId { get { return this._CrntStepId; } set { this._CrntStepId = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.CrntStepId); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "NEXT_STEP_ID")]
        public string NextStepId { get { return this._NextStepId; } set { this._NextStepId = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.NextStepId); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "OPER_TYPE")]
        public string OperType { get { return this._OperType; } set { this._OperType = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.OperType); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "OPER_RESULT")]
        public string OperResult { get { return this._OperResult; } set { this._OperResult = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.OperResult); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "CONTROL_FLAG")]
        public string ControlFlag { get { return this._ControlFlag; } set { this._ControlFlag = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.ControlFlag); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "REMARK")]
        public string Remark { get { return this._Remark; } set { this._Remark = value; if (this.DataModelBegin)AddEnum(SysStepConfigEnum.Remark); } }

        /// <summary>
        /// ????????:???????True?,????????,?????????????????????,???????????????????????????????????
        /// </summary>
        public void StartSetSQLValue()
        {
            this.DataModelBegin = true;
        }

        /// <summary>
        /// ???????
        /// </summary>
        public void EndSetSQLValue()
        {
            this.DataModelBegin = false;
        }

        private bool DataModelBegin;
        public List<SysStepConfigEnum> ListEnum { get; set; }

        public void AddEnum(SysStepConfigEnum item)
        {
            if (ListEnum == null) ListEnum = new List<SysStepConfigEnum>();
            if (!ListEnum.Contains(item))
            {
                ListEnum.Add(item);
            }
        }



        private SysStepConfigEnum _keyField;
        public SysStepConfigEnum KeyField { get { return this._keyField; } }

        public void SetKeyField(SysStepConfigEnum keyField)
        {
            this.HasSetKeyField = true;
            this._keyField = keyField;
        }

        public SysStepConfig()
        {
        }

        public SysStepConfig(SysStepConfigEnum keyField)
        {
            this.HasSetKeyField = true;
            this._keyField = keyField;
        }

        public bool HasSetKeyField { get; set; }

        public SysStepConfigEnum SortByField { get; set; }

        public SortDirection SortDirection { get; set; }


        public string SQLUpdate
        {
            get { return new SQLBuilder<SysStepConfig, SysStepConfigEnum>().Update(this); }
        }

        public string SQLInsert
        {
            get { return new SQLBuilder<SysStepConfig, SysStepConfigEnum>().Insert(this); }
        }

        public string SQLDelete
        {
            get { return new SQLBuilder<SysStepConfig, SysStepConfigEnum>().Delete(this); }
        }

        public string SQLSelect
        {
            get { return new SQLBuilder<SysStepConfig, SysStepConfigEnum>().Select(this); }
        }

        public void SetAllEnum()
        {
            new SQLBuilder<SysStepConfig, SysStepConfigEnum>().SetAllEnum(this);
        }

        private DataTable FetchDataTable()
        {
            return FetchDataTable(null);
        }

        private DataTable FetchDataTable(object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysStepConfig, SysStepConfigEnum>().GetDataTable(this, ts);
        }

        /// <summary>
        /// ???????????????????FetchEntity??????
        /// </summary>
        public bool HasFetchData { get; set; }

        /// <summary>
        /// ??????????????????????FetchEntity??????
        /// </summary>
        public bool NotFetchData { get { return !HasFetchData; } }

        /// <summary>
        /// ??????-???????SQL
        /// </summary>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysStepConfig FetchEntity()
        {
            return FetchEntity("", null);
        }

        /// <summary>
        /// ??????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysStepConfig FetchEntity(string sql)
        {
            return FetchEntity(sql, null);
        }

        /// <summary>
        /// ??????-???????SQL
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysStepConfig FetchEntity(object ts)
        {
            return FetchEntity("", ts);
        }

        /// <summary>
        /// ??????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <param name="ts">????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysStepConfig FetchEntity(string sql, object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysStepConfig, SysStepConfigEnum>().GetEntity(sql, this, ts);
        }

        /// <summary>
        /// ?????????-???????SQL
        /// </summary>
        /// <returns>??????</returns>
        public List<SysStepConfig> FetchEntities()
        {
            return FetchEntities("", null);
        }

        /// <summary>
        ///  ?????????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <returns>??????</returns>		
        public List<SysStepConfig> FetchEntities(string sql)
        {
            return FetchEntities(sql, null);
        }

        /// <summary>
        /// ?????????-???????SQL
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>??????</returns>
        public List<SysStepConfig> FetchEntities(object ts)
        {
            return FetchEntities("", ts);
        }

        /// <summary>
        ///  ?????????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <param name="ts">????</param>
        /// <returns>??????</returns>
        public List<SysStepConfig> FetchEntities(string sql, object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysStepConfig, SysStepConfigEnum>().GetEntities(sql, this, ts);
        }

        /// <summary>
        /// ?????????????
        /// </summary>
        /// <returns>True???? False??????</returns>
        public bool Exists()
        {
            return Exists(null);
        }

        /// <summary>
        ///  ?????????????
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>True???? False??????</returns>
        public bool Exists(object ts)
        {
            SysStepConfig item = this.FetchEntity(ts);
            return item.HasFetchData;
        }




    }


    public partial class SysStepConfig
    {
        private string _AutoId = "";
        private string _WorkflowType = "";
        private string _CrntStepId = "";
        private string _NextStepId = "";
        private string _OperType = "";
        private string _OperResult = "";
        private string _ControlFlag = "";
        private string _Remark = "";
    }


    public enum SysStepConfigEnum
    {
        ///<summary>
        ///[]
        ///</summary>
        AutoId,
        ///<summary>
        ///[]
        ///</summary>
        WorkflowType,
        ///<summary>
        ///[]
        ///</summary>
        CrntStepId,
        ///<summary>
        ///[]
        ///</summary>
        NextStepId,
        ///<summary>
        ///[]
        ///</summary>
        OperType,
        ///<summary>
        ///[]
        ///</summary>
        OperResult,
        ///<summary>
        ///[]
        ///</summary>
        ControlFlag,
        ///<summary>
        ///[]
        ///</summary>
        Remark
    }
}
